<?php
/*
 *	  nwlistform.php
 *	  
 *	  Copyright 2010 Vitaliy Rakitin <virak@ukr.net>
 *	  
 *	  This program is free software; you can redistribute it and/or modify
 *	  it under the terms of the GNU General Public License as published by
 *	  the Free Software Foundation; either version 2 of the License, or
 *	  (at your option) any later version.
 *	  
 *	  This program is distributed in the hope that it will be useful,
 *	  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	  GNU General Public License for more details.
 *	  
 *	  You should have received a copy of the GNU General Public License
 *	  along with this program; if not, write to the Free Software
 *	  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *	  MA 02110-1301, USA.
 */
 
require_once($_SERVER['DOCUMENT_ROOT']."/config.php"); 
require_once($_SERVER['DOCUMENT_ROOT']."/classes/system.php");

class nwform {
	
	protected $uuid;
	protected $body;
	protected $caption = "заголовок формы";
	//protected $top = 180;
	//protected $left = 200;
	//protected $dx;
	//protected $dy;
	//protected $ismove = false;
	//protected $components = array();
	private $minimaze = false;
	
	function __construct() {
		$this->uuid = genUUID();
	}

	function style() {
		return "border-style:solid;border-width:3px;border-color:#85C9FF;height: auto;background: #ECF1FE;opacity: 1;display: block;";
	}
	
	function form() {
		$out = "<div id='$this->uuid' style='".$this->style()."'>";
		$out .= "<div style='height: 27px;background: #D1E1FF;' ><table style='width: 100%;border-spacing: 0px;'><tr><td><b>".$this->caption."</b></td><td style='width: 70px;text-align:center;'>";
		if (!$this->minimaze) {$out .= "<input type='button' name='minimaze' value='_' onclick=message('$this->uuid','minimaze','',0);>";} else
		{$out .= "<input type='button' name='minimaze' value='<>' onclick=message('$this->uuid','minimaze','',0);>";}
		$out .= "<input type='button' name='close' value='X' onclick=message('$this->uuid','close','',0);></td></tr></table></div>";
		if (!$this->minimaze) {$out .= "<div style='opacity: 1;'>".$this->body."</div>";}
		$out .= "</div>";
		return $out;
	}
	
	function open() {
		$_SESSION[$this->uuid] = &$this;
		$answer = &$_SESSION['answer'];
		$answer[] = array('append',UUID_NWVIEVER,$this->form());
	}
	
	function show() {
		$this->open();
	}
	
	function get() {
		return $this->form();
	}
	
	function close() {
		$answer = &$_SESSION['answer'];
		$answer[] = array('delete',$this->uuid,'<br>');
		unset($_SESSION[$this->uuid]);
	}
	
	function update() {
		$answer = &$_SESSION['answer'];
		$answer[] = array('update',$this->uuid,$this->form());
	}
	
	function minimaze() {
		$this->minimaze = !$this->minimaze;
		$this->update();
	}
}
?>

